$(function(){
    $(".modify-pwd").on("click",function(){
        var id=$(".modify-pwd").attr("data-id");
        ShowPswdBox();
        $(".qr").on("click",function(){
            var old_pwd=$(".old_pwd").val();
            var pwd=$(".pwd").val();
            var re_pwd=$(".re_pwd").val();
            if(old_pwd==""||pwd==""||re_pwd==""){
                layer.msg("请完善信息")
            }else if(pwd!=re_pwd){
                layer.msg("两次密码输入不一致")
            }else{
                ajax("post","/admin/modify-pwd",{id:id,old_pwd:old_pwd,pwd:pwd,re_pwd:re_pwd},function success(data){
                    if(data.code==200){
                        layer.msg(data.msg);
                        setTimeout(function(){
                            location.href="/admin/login";
                        }, 1000);
                    }else{
                        layer.msg(data.msg);
                    }
                })
            }
        });
        $(".qx").on("click",function(){
            $(".filter").hide();
        })
    });
})

function ShowPswdBox(){
	var dIv=$("<div class='filter'><div class='pswd'><h3 class='m_p'>修改密码</h3><input type='password' class='old_pwd' placeholder='请输入旧密码'><input type='password' class='pwd' placeholder='请输入新密码'><input type='password' class='re_pwd' placeholder='请重新输入新密码'><div class='btn_box'><a class='btn qx'>取消</a><a class='btn btn-success qr'>确认</a></div></div></div>");
    $("body").append(dIv);
};